package org.t2.game.server.module.mail.model;

import java.util.ArrayList;
import java.util.List;

import org.banish.sql.core.annotation.Column;
import org.banish.sql.core.annotation.Table;
import org.banish.sql.core.annotation.enuma.AsyncType;
import org.gaming.prefab.mail.IMail;
import org.gaming.service.repository.annotation.JvmCache;
import org.gaming.service.service.jvm.PlayerOneToManyEntity;
import org.springframework.stereotype.Repository;

/**
 * @author yh
 * @date 2023/5/31
 * @apiNote
 */
@Repository
@JvmCache(relation = {"playerId", "idx"})
@Table(comment = "邮件表", dbAlias = "game", asyncType = AsyncType.UPDATE)
public class Mail extends PlayerOneToManyEntity implements IMail {
	@Column(comment = "邮件模板ID", readonly = true)
	private int template;
	@Column(comment = "标题参数", readonly = true, length = 500)
	private List<String> titleArgs = new ArrayList<>();
	@Column(comment = "内容参数", readonly = true, length = 5000)
	private List<String> contentArgs = new ArrayList<>();
	@Column(comment = "附件", readonly = true, extra = "text")
	private String attachment;
	@Column(comment = "是否已读")
	private boolean read;
	@Column(comment = "是否已领")
	private boolean receive;
	@Column(comment = "到期时间", readonly = true, extra = "time")
	private long expireTime;
	@Column(comment = "游戏事件")
	private int gameCause;
	@Column(comment = "游戏事件")
	private String gameCauseText;
	@Column(comment = "来自哪个系统邮件")
	private long fromPoolId;
	
	public int getTemplate() {
		return template;
	}
	public void setTemplate(int template) {
		this.template = template;
	}
	public List<String> getTitleArgs() {
		return titleArgs;
	}
	public void setTitleArgs(List<String> titleArgs) {
		this.titleArgs = titleArgs;
	}
	public List<String> getContentArgs() {
		return contentArgs;
	}
	public void setContentArgs(List<String> contentArgs) {
		this.contentArgs = contentArgs;
	}
	public String getAttachment() {
		return attachment;
	}
	public void setAttachment(String attachment) {
		this.attachment = attachment;
	}
	public boolean isRead() {
		return read;
	}
	public void setRead(boolean read) {
		this.read = read;
	}
	public boolean isReceive() {
		return receive;
	}
	public void setReceive(boolean receive) {
		this.receive = receive;
	}
	@Override
	public void markUnread() {
		this.read = false;
	}
	@Override
	public void markRead() {
		this.read = true;
	}
	@Override
	public void markUnreceive() {
		this.receive = false;
	}
	@Override
	public void markReceive() {
		this.receive = true;
	}
	public int getGameCause() {
		return gameCause;
	}
	public void setGameCause(int gameCause) {
		this.gameCause = gameCause;
	}
	public String getGameCauseText() {
		return gameCauseText;
	}
	public void setGameCauseText(String gameCauseText) {
		this.gameCauseText = gameCauseText;
	}
	public long getFromPoolId() {
		return fromPoolId;
	}
	public void setFromPoolId(long fromPoolId) {
		this.fromPoolId = fromPoolId;
	}
	@Override
	public long getReceiver() {
		return playerId;
	}
	@Override
	public void setReceiver(long receiver) {
		this.playerId = receiver;
	}
	public long getExpireTime() {
		return expireTime;
	}
	public void setExpireTime(long expireTime) {
		this.expireTime = expireTime;
	}
	@Override
	public long getId() {
		return idx;
	}
}
